/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.common.client.model;

import java.util.Date;

import com.google.gwt.json.client.JSONObject;

/**
 *  
 */
public class AccountAdministrationModel extends AbstractModel
{
	protected int id;
	protected String firstname;
	protected String lastname;
	protected String email;
	protected String telephone;
	protected String fax;
	protected boolean wholesale;
	protected boolean isLogin;
	protected Date dateCreated;
	protected Date dateModified;
	protected Date lastLogin;
	protected int numberOfLogins;
	protected int numberOfReviews;
	protected String countryName;
	
	public AccountAdministrationModel() 
	{
		id = -1;
		firstname = "";
		lastname = "";
		email = "";
		telephone = "";
		fax = "";
		wholesale = false;
		isLogin = false;
		dateCreated = null;
		dateModified = null;
		lastLogin = null;
		numberOfLogins = 0;
		numberOfReviews = 0;
		countryName = "";
	}
	
	public AccountAdministrationModel(JSONObject jsonObject)
	{
		id = convertToInteger(jsonObject, "id");
		firstname = convertToString(jsonObject, "firstname");
		lastname = convertToString(jsonObject, "lastname");
		email = convertToString(jsonObject, "email");
		telephone = convertToString(jsonObject, "telephone");
		fax = convertToString(jsonObject, "fax");
		wholesale = convertToBoolean(jsonObject, "wholesale");
		isLogin = convertToBoolean(jsonObject, "isLogin");
		dateCreated = convertToDate(jsonObject, "date_created");
		dateModified = convertToDate(jsonObject, "date_modified");
		lastLogin = convertToDate(jsonObject, "last_login");
		numberOfLogins = convertToInteger(jsonObject, "number_of_logins");
		numberOfReviews = convertToInteger(jsonObject, "number_of_reviews");
		countryName = convertToString(jsonObject, "countries_name");
	}
	
	public AccountAdministrationModel(AccountAdministrationModel model) 
	{
		id = model.getId();
		firstname = model.getFirstname();
		lastname = model.getLastname();
		email = model.getEmail();
		telephone = model.getTelephone();
		fax = model.getFax();
		wholesale = model.isWholesale();
		isLogin = model.isLogin();
		dateCreated = model.getDateCreated();
		dateModified = model.getDateModified();
		lastLogin = model.getLastLogin();
		numberOfLogins = model.getNumberOfLogins();
		numberOfReviews = model.getNumberOfReviews();
		countryName = model.getCountryName();
	}
	
	public int getId() {
		return id;
	}

	public String getFirstname() {
		return firstname;
	}

	public String getLastname() {
		return lastname;
	}
	
	public String getEmail() {
		return email;
	}

	public String getTelephone() {
		return telephone;
	}

	public String getFax() {
		return fax;
	}

	public boolean isWholesale() {
		return wholesale;
	}

	public boolean isLogin() {
		return isLogin;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public Date getDateModified() {
		return dateModified;
	}

	public Date getLastLogin() {
		return lastLogin;
	}

	public int getNumberOfLogins() {
		return numberOfLogins;
	}

	public int getNumberOfReviews() {
		return numberOfReviews;
	}

	public String getCountryName() {
		return countryName;
	}
}
